Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Effect.transposeOption, closes #3142 #4284

Merged
merged 1 commit into from
Jan 21, 2025
Merged

Add Effect.transposeOption, closes #3142 #4284

merged 1 commit into from
Jan 21, 2025

Conversation

gcanti
Copy link
Contributor

@gcanti gcanti commented Jan 17, 2025

Converts an Option of an Effect into an Effect of an Option.

Details

This function transforms an Option<Effect<A, E, R>> into an
Effect<Option<A>, E, R>. If the Option is None, the resulting Effect
will immediately succeed with a None value. If the Option is Some, the
inner Effect will be executed, and its result wrapped in a Some.

Example

import { Effect, Option } from "effect"

//      ┌─── Option<Effect<number, never, never>>
//      ▼
const maybe = Option.some(Effect.succeed(42))

//      ┌─── Effect<Option<number>, never, never>
//      ▼
const result = Effect.transposeOption(maybe)

console.log(Effect.runSync(result))
// Output: { _id: 'Option', _tag: 'Some', value: 42 }

@gcanti gcanti requested a review from mikearnaldi as a code owner January 17, 2025 09:40
Copy link

changeset-bot bot commented Jan 17, 2025

🦋 Changeset detected

Latest commit: 2269653

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 35 packages
Name Type
effect Minor
@effect/cli Major
@effect/cluster-browser Major
@effect/cluster-node Major
@effect/cluster-workflow Major
@effect/cluster Major
@effect/experimental Major
@effect/opentelemetry Major
@effect/platform-browser Major
@effect/platform-bun Major
@effect/platform-node-shared Major
@effect/platform-node Major
@effect/platform Major
@effect/printer-ansi Major
@effect/printer Major
@effect/rpc-http Major
@effect/rpc Major
@effect/sql-clickhouse Major
@effect/sql-d1 Major
@effect/sql-drizzle Major
@effect/sql-kysely Major
@effect/sql-libsql Major
@effect/sql-mssql Major
@effect/sql-mysql2 Major
@effect/sql-pg Major
@effect/sql-sqlite-bun Major
@effect/sql-sqlite-do Major
@effect/sql-sqlite-node Major
@effect/sql-sqlite-react-native Major
@effect/sql-sqlite-wasm Major
@effect/sql Major
@effect/typeclass Major
@effect/vitest Major
@effect/ai Major
@effect/ai-openai Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-bot effect-bot force-pushed the next-minor branch 5 times, most recently from 71cc094 to 285961b Compare January 18, 2025 18:18
@tim-smart
Copy link
Contributor

/rebase

@effect-bot effect-bot force-pushed the next-minor branch 9 times, most recently from 6e5eda9 to a7dd86e Compare January 21, 2025 02:12
@tim-smart
Copy link
Contributor

/rebase

@gcanti gcanti merged commit debf84b into next-minor Jan 21, 2025
12 checks passed
@gcanti gcanti deleted the fix-3142 branch January 21, 2025 06:22
effect-bot pushed a commit that referenced this pull request Jan 21, 2025
effect-bot pushed a commit that referenced this pull request Jan 21, 2025
effect-bot pushed a commit that referenced this pull request Jan 21, 2025
effect-bot pushed a commit that referenced this pull request Jan 21, 2025
effect-bot pushed a commit that referenced this pull request Jan 21, 2025
effect-bot pushed a commit that referenced this pull request Jan 21, 2025
effect-bot pushed a commit that referenced this pull request Jan 21, 2025
effect-bot pushed a commit that referenced this pull request Jan 21, 2025
effect-bot pushed a commit that referenced this pull request Jan 21, 2025
effect-bot pushed a commit that referenced this pull request Jan 22, 2025
effect-bot pushed a commit that referenced this pull request Jan 22, 2025
effect-bot pushed a commit that referenced this pull request Jan 22, 2025
effect-bot pushed a commit that referenced this pull request Jan 22, 2025
effect-bot pushed a commit that referenced this pull request Jan 22, 2025
effect-bot pushed a commit that referenced this pull request Jan 22, 2025
effect-bot pushed a commit that referenced this pull request Jan 22, 2025
effect-bot pushed a commit that referenced this pull request Jan 22, 2025
effect-bot pushed a commit that referenced this pull request Jan 23, 2025
effect-bot pushed a commit that referenced this pull request Jan 23, 2025
effect-bot pushed a commit that referenced this pull request Jan 23, 2025
effect-bot pushed a commit that referenced this pull request Jan 23, 2025
effect-bot pushed a commit that referenced this pull request Jan 24, 2025
effect-bot pushed a commit that referenced this pull request Jan 24, 2025
effect-bot pushed a commit that referenced this pull request Jan 24, 2025
effect-bot pushed a commit that referenced this pull request Jan 25, 2025
effect-bot pushed a commit that referenced this pull request Jan 25, 2025
effect-bot pushed a commit that referenced this pull request Jan 27, 2025
effect-bot pushed a commit that referenced this pull request Jan 28, 2025
effect-bot pushed a commit that referenced this pull request Jan 28, 2025
effect-bot pushed a commit that referenced this pull request Jan 28, 2025
effect-bot pushed a commit that referenced this pull request Jan 28, 2025
effect-bot pushed a commit that referenced this pull request Jan 28, 2025
effect-bot pushed a commit that referenced this pull request Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants